home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0391B.ZIP / JWINDOW.ARC / JERWIND.INC < prev    next >
Text File  |  1985-09-15  |  5KB  |  121 lines

  1. { Program JERWIND.INC       Ver 1.2
  2.   Author  Jerry S. Lamphere  - Copyright 1985
  3.           208 Highland St.
  4.           Fulton NY, 13069
  5.  
  6.      The Purpose of this program was the need to display windows for
  7.    error messages, and displaying of Misc. Data without Destroying the
  8.    integrity of the main screen being worked.  I did not set the program
  9.    up to do Multiple windows since most of my applications don't require
  10.    the need for it.  The only things you may have to change is values that
  11.    define each window in Wtab and the number, also if you are using a
  12.    Monochrome Card - the address specified in Card_type from $B800:0000
  13.    to $B000:0000 since direct addressing is done to the screen memory.
  14.  
  15.      Since this is just the very basics of doing windowing with TURBO
  16.    I did not include any routines to save the backround for foreground
  17.    colors before opening a window, although it could be done rather easily,
  18.    I find it just as easy to restore them myself when I go back to the
  19.    original screen.  Although there are fancier routines for manipulating
  20.    windows and multiple windows, this should meet the needs of most quick
  21.    little programs.  If you have never done windowing and wondered how some
  22.    programs handle it maybe this will give some insight to that end.  This
  23.    routine is copyrighted since it was part of a major program I did, however
  24.    you may freely utilize these procedures in any of your programs.  }
  25.  
  26.  
  27.     Const  Wtab :array [1..4,1..6] of integer  {4 windows with 6 parameters.}
  28.  
  29.            { Now we will define all of our window parameters in the array
  30.              the first four positions are the where we wish to open the
  31.              window, then window border color, followed by the backround
  32.              color for the window. }
  33.  
  34.                 = (( 10, 3, 70, 20, 5, 7),   {Window 1}
  35.                    ( 12, 7, 68, 18, 7, 9),   {Window 2}
  36.                    ( 10, 5, 70, 15, 6, 12),   {Window 3}
  37.                    ( 15, 6, 65, 20, 3, 0));  {Window 4}
  38.  
  39.  
  40.     Var  Screen_Dat  : array [1..25] of String [160]; {Array where we will
  41.                                                        store the screen be-
  42.                                                        fore opening a window }
  43.           Sav_X, Sav_Y,
  44.           Wind_open, I    : Integer;    { Where we store cursor position
  45.                                           also wehter a window is open   }
  46.  
  47.  
  48.  
  49.  
  50.        Card_type  : Char absolute $B800:0000;  {scrn address for color card}
  51.  
  52.  
  53.     { This is the start of the procedure to close an existing window
  54.       and restore the screen to it's previous self                    }
  55.  
  56.      Procedure  Close_Window;
  57.  
  58.      Begin
  59.            Move ( Screen_Dat, Card_type, 4000);
  60.            Window (1,1,80,24);
  61.            Gotoxy (Sav_X, Sav_Y);             { Restore Cursor }
  62.            Wind_open := 0;
  63.      End;
  64.     Procedure  Open_Window (Screen : integer);
  65.  
  66.          { Screen has the array number of the window we want to open }
  67.  
  68.       Var     I :Byte;
  69.  
  70.      Begin
  71.        If (Wind_open = 1) then
  72.         Begin
  73.          Textbackground(0);  {help eliminate flash when changing windows }
  74.         Close_Window; {Have one open so Close it first
  75.                                               to keep a neater scrren        }
  76.          End;
  77.  
  78.        Move ( Card_type, Screen_Dat, 4000); { Save Screen as is }
  79.        Sav_X := WhereX;                    { Save X location of cursor }
  80.        Sav_Y := WhereY;                    { Save Y location of cursor }
  81.  
  82.         { Hopefully everything that needed saving is done so let's get going }
  83.  
  84.         Window ( Wtab[Screen,1], Wtab[Screen,2],     {Start of window}
  85.                 Wtab[Screen,3], Wtab[Screen,4]  );   {Bottom of window}
  86.  
  87.         Clrscr;
  88.           { Do the window Border colors }
  89.  
  90.           TextColor       ( Wtab[Screen,5] );        { Border color }
  91.           TextBackground  ( Wtab[Screen,6] );        { Background color }
  92.  
  93.           { Now to frame }
  94.  
  95.        Gotoxy (1,1); Write ('╒');
  96.               For I := 2 to Wtab[screen,3] - Wtab[Screen,1] do
  97.                 Write ('═');
  98.                 Write ('╕');
  99.               For I :=2 to Wtab[Screen,4] - Wtab[Screen,2] do
  100.          Begin
  101.                Gotoxy (1,I); Write ('│');
  102.                Gotoxy (Wtab[screen,3] - Wtab[Screen,1] + 1, I);
  103.                Write ('│');
  104.          End;
  105.               Gotoxy (1, Wtab[Screen,4] - Wtab[Screen,2] + 1); Write ('╘');
  106.               For I := 2 to Wtab[Screen,3] - Wtab[Screen,1] do
  107.                    Write ('═');
  108.               {     Write ('╛');   }
  109.        { Since we put a frame around the window better make a new one so
  110.          we don't have to worry about writing over the border            }
  111.  
  112.           Window (Wtab[screen,1] + 1, Wtab[Screen,2] + 1,
  113.                   Wtab[Screen,3] - 1, Wtab[Screen,4] - 1 );
  114.           Write ('╛');
  115.           TextColor (7);
  116.           Wind_open := 1;
  117.           CLRSCR;
  118.        End;            { End of procedure to open a window }
  119.  
  120.  
  121.